using System;
using System.Collections.Generic;
using System.Text;
using Forecast.Database;

namespace Forecast.Business
{
    internal class HiddenHolding
    {
        private int _numHiddenStocks;

        internal HiddenHolding(Player player, Prediction prediction, IList<Offer> allActiveOffersInPrediction)
        {
            foreach (Offer offer in allActiveOffersInPrediction)
            {
                // These two guards should be unnecessary
                if (!offer.IsActive)
                    continue;
                if (offer.PredictionId != prediction.Id)
                    continue;

                // These two guards are necessary
                if (offer.PlayerId != player.Id)
                    continue;                
                if (offer.IsBuy)
                    continue;
                
                _numHiddenStocks += offer.NumPredictions;
            }
        }

        internal int NumHiddenStocks { get { return _numHiddenStocks; } }
    }
}
